﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Jayden.Dll.Core;
using System.Globalization;
using System.Threading;

namespace RealNumberTest
{
	class Program
	{
		static void Main(string[] args)
		{

			RealNumber zero = 0;
			RealNumber one = 1;
			RealNumber three = 3;
			RealNumber four = 4;
			RealNumber five = 5;
			RealNumber nine = 9;
			RealNumber oneTwoThreeFour = 1234;
			RealNumber ten = 10;
			RealNumber tenth = 0.1;
			RealNumber hundred = 100;
			RealNumber minHundred = -100;
			RealNumber percent = 0.01;
			RealNumber a = 0.125;
			RealNumber b = 1024.125;
			RealNumber mille = 1000;
			RealNumber c = 1.00000000000015;
			RealNumber d = 1.0000000000000000000000000015M;
			RealNumber pi = RealNumber.Pi(50);
			RealNumber e = RealNumber.E(50);
			
			//Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
			Console.WriteLine("RealNumber test cases : (display format is based on {0} culture).", CultureInfo.CurrentCulture);
			Console.WriteLine();
			Console.WriteLine("zero.ToString() = {0}", zero);
			Console.WriteLine("one.ToString() = {0}", one);
			Console.WriteLine("three.ToString() = {0}", three);
			Console.WriteLine("oneTwoThreeFour.ToString() = {0}", oneTwoThreeFour);
			Console.WriteLine("four.ToString() = {0}", four);
			Console.WriteLine("five.ToString() = {0}", five);
			Console.WriteLine("nine.ToString() = {0}", nine);
			Console.WriteLine("ten.ToString() = {0}", ten);
			Console.WriteLine("tenth.ToString() = {0}", tenth);
			Console.WriteLine("hundred.ToString() = {0}", hundred);
			Console.WriteLine("minHundred.ToString() = {0}", minHundred);
			Console.WriteLine("percent.ToString() = {0}", percent);
			Console.WriteLine("mille.ToString() = {0}", mille);
			Console.WriteLine("a.ToString() = {0}", a);
			Console.WriteLine("b.ToString() = {0}", b);
			Console.WriteLine("c.ToString() = {0}", c);
			Console.WriteLine("d.ToString() = {0}", d);
			Console.WriteLine();
			Console.WriteLine("zero.CompareTo(one) = {0}", zero.CompareTo(one));
			Console.WriteLine("one.CompareTo(percent) = {0}", one.CompareTo(percent));
			Console.WriteLine("tenth.CompareTo(tenth.Clone()) = {0}", tenth.CompareTo(tenth.Clone()));
			Console.WriteLine();
			Console.WriteLine("percent[2] = {0}", percent[2]);
			Console.WriteLine("percent[1] = {0}", percent[1]);
			Console.WriteLine("percent[0] = {0}", percent[0]);
			Console.WriteLine("percent[-1] = {0}", percent[-1]);
			Console.WriteLine("percent[-2] = {0}", percent[-2]);
			Console.WriteLine();
			Console.WriteLine("one.Add(percent) = {0}", one.Add(percent));
			Console.WriteLine("one.Add(one) = {0}", one.Add(one));
			Console.WriteLine("one.Add(nine) = {0}", one.Add(nine));
			Console.WriteLine();
			Console.WriteLine("one.Subtract(percent) = {0}", one.Subtract(percent));
			Console.WriteLine("hundred.Subtract(minHundred) = {0}", hundred.Subtract(minHundred));
			Console.WriteLine("one.Subtract(hundred) = {0}", one.Subtract(hundred));
			Console.WriteLine();
			Console.WriteLine("percent.Multiply(nine) = {0}", percent.Multiply(nine));
			Console.WriteLine("oneTwoThreeFour.Multiply(nine.Add(ten).Multiply(percent)) = {0}", oneTwoThreeFour.Multiply(nine.Add(ten).Multiply(percent)));
			Console.WriteLine();
			Console.WriteLine("one.Divide(five) = {0}", one.Divide(five));
			Console.WriteLine("one / five = {0}", one / five);
			Console.WriteLine("one.Divide(four) = {0}", one.Divide(four));
			Console.WriteLine("ten.Divide(four) = {0}", ten.Divide(four));
			Console.WriteLine("percent.Divide(four) = {0}", percent.Divide(four));
			Console.WriteLine("ten.Add(percent).Divide(four) = {0}", ten.Add(percent).Divide(four));
			Console.WriteLine("(RealNumber)(22) / (RealNumber)(7) = {0}", (RealNumber)(22) / (RealNumber)(7));
			Console.WriteLine("(RealNumber)(1) / (RealNumber)(7) = {0}", (RealNumber)(1) / (RealNumber)(7));
			Console.WriteLine("(RealNumber)(10) / (RealNumber)(7) = {0}", (RealNumber)(10) / (RealNumber)(7));
			Console.WriteLine("(RealNumber)(1) / (RealNumber)(70) = {0}", (RealNumber)(1) / (RealNumber)(70));
			Console.WriteLine("(RealNumber)(1) / (RealNumber)(81) = {0}", (RealNumber)(1) / (RealNumber)(81));
			Console.WriteLine("(RealNumber)(1) / (RealNumber)(29) = {0}", (RealNumber)(1) / (RealNumber)(29));
			Console.WriteLine("(RealNumber)(1) / (RealNumber)(97) = {0}", (RealNumber)(1) / (RealNumber)(97));
			Console.WriteLine("one / three = {0}", one / three);
			Console.WriteLine();
			Console.WriteLine("RealNumber.Factorial(100) = {0}", RealNumber.Factorial(100));
			Console.WriteLine("RealNumber.Factorial(50) = {0}", RealNumber.Factorial(50));
			Console.WriteLine("RealNumber.Factorial(20) = {0}", RealNumber.Factorial(20));
			Console.WriteLine("RealNumber.Factorial(10) = {0}", RealNumber.Factorial(10));
			Console.WriteLine();
			Console.WriteLine("RealNumber.Sqrt(10) = {0}", RealNumber.Sqrt(10));
			Console.WriteLine("RealNumber.Sqrt(1) = {0}", RealNumber.Sqrt(1));
			Console.WriteLine("RealNumber.Sqrt(4) = {0}", RealNumber.Sqrt(4));
			Console.WriteLine("RealNumber.Sqrt(9) = {0}", RealNumber.Sqrt(9));
			Console.WriteLine("RealNumber.Sqrt(2) = {0}", RealNumber.Sqrt(2));
			Console.WriteLine("RealNumber.Sqrt(16) = {0}", RealNumber.Sqrt(16));
			Console.WriteLine();
			Console.WriteLine("pi = {0}", pi);
			Console.WriteLine("e = {0}", e);
			Console.WriteLine("RealNumber.Round(pi, 15, MidpointRounding.AwayFromZero) = {0}", RealNumber.Round(pi, 15, MidpointRounding.AwayFromZero));
			Console.WriteLine("RealNumber.Round(pi, 17, MidpointRounding.AwayFromZero) = {0}", RealNumber.Round(pi, 17, MidpointRounding.AwayFromZero));
			Console.WriteLine();
			Console.WriteLine("RealNumber.Sin(1) = {0}", RealNumber.Round(RealNumber.Sin(1), 50, MidpointRounding.AwayFromZero));
			Console.WriteLine("RealNumber.Sin(0) = {0}", RealNumber.Round(RealNumber.Sin(0), 50, MidpointRounding.AwayFromZero));
			Console.WriteLine("RealNumber.Sin(pi) = {0}", RealNumber.Round(RealNumber.Sin(pi), 50, MidpointRounding.AwayFromZero));
			Console.WriteLine("RealNumber.Cos(1) = {0}", RealNumber.Round(RealNumber.Cos(1), 50, MidpointRounding.AwayFromZero));
			Console.WriteLine("RealNumber.Cos(0) = {0}", RealNumber.Round(RealNumber.Cos(0), 50, MidpointRounding.AwayFromZero));
			Console.WriteLine("RealNumber.Cos(pi) = {0}", RealNumber.Round(RealNumber.Cos(pi), 50, MidpointRounding.AwayFromZero));
			Console.WriteLine("RealNumber.Tan(1) = {0}", RealNumber.Round(RealNumber.Tan(1), 50, MidpointRounding.AwayFromZero));
			Console.WriteLine("RealNumber.Tan(0) = {0}", RealNumber.Round(RealNumber.Tan(0), 50, MidpointRounding.AwayFromZero));
			Console.WriteLine("RealNumber.Tan(pi) = {0}", RealNumber.Round(RealNumber.Tan(pi), 50, MidpointRounding.AwayFromZero));
			Console.WriteLine();
			Console.WriteLine("(decimal)pi = {0}", (decimal)pi);
			Console.WriteLine("(double)pi = {0}", (double)pi);
			Console.WriteLine("(float)pi = {0}", (float)pi);
			Console.WriteLine("(long)b = {0}", (long)b);
			Console.WriteLine("(ulong)b = {0}", (ulong)b);
			Console.WriteLine("(byte)b = {0}", (byte)b);
			Console.WriteLine();

			Console.Write("=== press any key to exit ===");
			Console.ReadKey(true);
		}
	}
}
